﻿<!DOCTYPE html>
<!--HTML5 doctype-->
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<title>站内短信息 - {site.name}</title>
<meta name="keywords" content="{site.seo_keyword}" />
<meta name="description" content="{site.seo_description}" />
<link rel="stylesheet" type="text/css" href="<%templateskin%>/css/style.css" />
<script type="text/javascript" charset="utf-8" src="<%templateskin%>/js/zepto.min.js"></script>
<script type="text/javascript" charset="utf-8" src="<%templateskin%>/js/weui.min.js"></script>
<script type="text/javascript" charset="utf-8" src="<%templateskin%>/js/common.js"></script>
<script type="text/javascript">
	function ExecPostBack(checkValue) {
		if (arguments.length == 1) {
			ExecDelete('{config.webpath}tools/submit_ajax.ashx?action=user_message_delete', checkValue, '#turl');
		}else{
			var valueArr = '';
			$("input[name='checkId']:checked").each(function(i){
				valueArr += $(this).val();
				if(i < $("input[name='checkId']:checked").length - 1){
					valueArr += ","
				}
			});
			ExecDelete('{config.webpath}tools/submit_ajax.ashx?action=user_message_delete', valueArr, '#turl');
		}
    }
</script>
</head>

<body ontouchstart>
<div class="page">
    <!--页面头部-->
    <div class="header">
        <a class="back" href="javascript:history.back();">
            <i class="iconfont icon-arrow-left"></i>
        </a>
        <h3>站内短消息</h3>
        <div class="right"> 
            <a class="weui-cell_access weui-cell_link" href="<%linkurl("usercenter","index")%>">
                <i class="iconfont icon-user"></i>
            </a>
        </div>
    </div>
    <!--/页面头部-->
    
    <div class="page__bd">

        <%if(action=="add")%>
        <!--发送消息-->
        <link rel="stylesheet" type="text/css" href="<%templateskin%>/css/validate.css" />
        <script type="text/javascript" charset="utf-8" src="<%templateskin%>/js/mvalidate.js"></script>
        <script type="text/javascript" charset="utf-8" src="<%templateskin%>/js/mvalidate-extend.js"></script>
        <script type="text/javascript">
            $(function(){
                //初始化表单
                AjaxInitForm('#addForm', '#btnSubmit', 1, '#turl');
                //选中TAB样式
                $(".weui-tabbar a").eq(0).addClass("weui-bar__item_on");
            });
        </script>
        <form id="addForm" name="addForm" url="{config.webpath}tools/submit_ajax.ashx?action=user_message_add">
        <div class="weui-panel weui-panel_access" style="margin-top:10px;">
            <div class="weui-panel__hd">发送消息</div>
            <div class="weui-panel__bd">
                <div class="weui-cells_form form-box">
                    <div class="weui-cell">
                        <div class="weui-cell__hd">
                            <label class="weui-label">收件人</label>
                        </div>
                        <div class="weui-cell__bd">
                            <input id="txtUserName" name="txtUserName" class="weui-input" type="text" placeholder="收件人用户名" data-validate="username" />
                        </div>
                    </div>
                    <div class="weui-cell">
                        <div class="weui-cell__hd">
                            <label class="weui-label">标题</label>
                        </div>
                        <div class="weui-cell__bd">
                            <input id="txtTitle" name="txtTitle" class="weui-input" type="text" placeholder="请输入标题" data-validate="s" />
                        </div>
                    </div>
                    <div class="weui-cell">
                        <div class="weui-cell__bd">
                            <textarea name="txtContent" class="weui-textarea" placeholder="请输入内容" rows="3"></textarea>
                        </div>
                    </div>
                    <div class="weui-cell">
                        <div class="weui-cell__hd">
                            <label class="weui-label">验证码</label>
                        </div>
                        <div class="weui-cell__bd">
                            <input id="txtCode" name="txtCode" class="weui-input" type="text" placeholder="请输入验证码" data-validate="code" />
                        </div>
                        <div class="weui-cell__ft">
                            <a href="javascript:;" onclick="ToggleCode(this, '{config.webpath}tools/verify_code.ashx');return false;">
                            <img class="weui-vcode-img" src="{config.webpath}tools/verify_code.ashx" style="width:82px;height:24px;" />
                            </a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        
        <div class="weui-panel weui-panel_access">
            <div class="weui-panel__bd">
                <div class="weui-cells_form form-box">
                    <div class="weui-cell weui-cell_switch">
                        <div class="weui-cell__bd">保存到发件箱</div>
                        <div class="weui-cell__ft">
                            <input id="sendSave" name="sendSave" type="checkbox" class="weui-switch" value="true" checked="checked" />
                        </div>
                    </div>
                </div>
            </div>
        </div>
        
        <div class="weui-btn-area">
            <input id="btnSubmit" name="btnSubmit" type="submit" class="weui-btn weui-btn_primary" value="确认发送" />
        </div>
        </form>
        <!--发送消息-->

        <%else if(action=="system")%>
        <!--系统消息-->
        <script type="text/javascript">
            $(function(){
                //选中TAB样式
                $(".weui-tabbar a").eq(1).addClass("weui-bar__item_on");
            });
        </script>
        
        <div class="detail-list">
            <ul>
                <!--取得一个DataTable-->
                <%set DataTable messageList=get_user_message_list(10, page, "accept_user_name='"+userModel.user_name+"' and type=1", out totalcount)%>
                <!--取得分页页码列表-->
                <%set string pagelist=get_page_link(10, page, totalcount, "usermessage", action, "__id__")%>
                <%foreach(DataRow dr in messageList.Rows)%>
                <li>
                    <div class="detail-bd">
                        <div class="list-box">
                            <div class="txt-box">
                                <h2>{dr[title]}</h2>
                                <p class="note">
                                    <span class="fr">
                                        <%if({dr[is_read]}=="1")%>
                                            已读
                                        <%else%>
                                            未读
                                        <%/if%>
                                    </span>
                                    <span>{dr[post_time]}</span>
                                </p>
                            </div>
                        </div>
                    </div>
                    <div class="detail-ft">
                        <div class="ft-btn">
                            <div class="btn-box">
                                <a href="<%linkurl("usermessage_show",{dr[id]})%>">查看详情</a>
                                <a href="javascript:;" onclick="ExecPostBack('{dr[id]}');">
                                    <i class="iconfont icon-delete"></i>
                                    删除
                                </a>
                            </div>
                        </div>
                    </div>
                </li>
                <%/foreach%>
                <%if(messageList.Rows.Count==0)%>
                <div class="nodata">暂无记录...</div>
                <%/if%>
            </ul>
        </div>
        
        <!--分页页码-->
        <div class="page-list">
            {pagelist}
        </div>
        <!--/分页页码-->
        
        <input id="turl" type="hidden" value="<%linkurl("usermessage","system")%>" /><!--存在跳转的URL值-->
        <!--/系统消息-->
        
        <%else if(action=="accept")%>
        <!--收件箱-->
        <script type="text/javascript">
            $(function(){
                //选中TAB样式
                $(".weui-tabbar a").eq(2).addClass("weui-bar__item_on");
            });
        </script>
        
        <div class="detail-list">
            <ul>
                <!--取得一个DataTable-->
                <%set DataTable messageList=get_user_message_list(10, page, "accept_user_name='"+userModel.user_name+"' and type=2", out totalcount)%>
                <!--取得分页页码列表-->
                <%set string pagelist=get_page_link(10, page, totalcount, "usermessage", action, "__id__")%>
                <%foreach(DataRow dr in messageList.Rows)%>
                <li>
                    <div class="detail-bd">
                        <div class="list-box">
                            <div class="img-box">
                                <%set string user_avatar=get_user_avatar({dr[post_user_name]})%>
                                <%if(user_avatar=="")%>
                                <i class="iconfont icon-user-full"></i>
                                <%else%>
                                <img src="{user_avatar}" alt="{dr[post_user_name]}" />
                                <%/if%>
                            </div>
                            <div class="txt-box">
                                <h2>{dr[title]}</h2>
                                <p>发件人 {dr[post_user_name]}</p>
                                <p class="note">
                                    <span class="fr">
                                        <%if({dr[is_read]}=="1")%>
                                            已读
                                        <%else%>
                                            未读
                                        <%/if%>
                                    </span>
                                    <span>{dr[post_time]}</span>
                                </p>
                            </div>
                        </div>
                    </div>
                    <div class="detail-ft">
                        <div class="ft-btn">
                            <div class="btn-box">
                                <a href="<%linkurl("usermessage_show",{dr[id]})%>">查看详情</a>
                                <a href="javascript:;" onclick="ExecPostBack('{dr[id]}');">
                                    <i class="iconfont icon-delete"></i>
                                    删除
                                </a>
                            </div>
                        </div>
                    </div>
                </li>
                <%/foreach%>
                <%if(messageList.Rows.Count==0)%>
                <div class="nodata">暂无记录...</div>
                <%/if%>
            </ul>
        </div>
        
        <!--分页页码-->
        <div class="page-list">
            {pagelist}
        </div>
        <!--/分页页码-->
        
        <input id="turl" type="hidden" value="<%linkurl("usermessage","accept")%>" /><!--存在跳转的URL值-->
        <!--/收件箱-->
        
        <%else if(action=="send")%>
        <!--发件箱-->
        <script type="text/javascript">
            $(function(){
                //选中TAB样式
                $(".weui-tabbar a").eq(3).addClass("weui-bar__item_on");
            });
        </script>
        
        <div class="detail-list">
            <ul>
                <!--取得一个DataTable-->
                <%set DataTable messageList=get_user_message_list(10, page, "accept_user_name='"+userModel.user_name+"' and type=3", out totalcount)%>
                <!--取得分页页码列表-->
                <%set string pagelist=get_page_link(10, page, totalcount, "usermessage", action, "__id__")%>
                <%foreach(DataRow dr in messageList.Rows)%>
                <li>
                    <div class="detail-bd">
                        <div class="list-box">
                            <div class="img-box">
                                <%set string user_avatar=get_user_avatar({dr[accept_user_name]})%>
                                <%if(user_avatar=="")%>
                                <i class="iconfont icon-user-full"></i>
                                <%else%>
                                <img src="{user_avatar}" alt="{dr[post_user_name]}" />
                                <%/if%>
                            </div>
                            <div class="txt-box">
                                <h2>{dr[title]}</h2>
                                <p>收件人 {dr[accept_user_name]}</p>
                                <p>{dr[post_time]}</p>
                            </div>
                        </div>
                    </div>
                    <div class="detail-ft">
                        <div class="ft-btn">
                            <div class="btn-box">
                                <a href="<%linkurl("usermessage_show",{dr[id]})%>">查看详情</a>
                                <a href="javascript:;" onclick="ExecPostBack('{dr[id]}');">
                                    <i class="iconfont icon-delete"></i>
                                    删除
                                </a>
                            </div>
                        </div>
                    </div>
                </li>
                <%/foreach%>
                <%if(messageList.Rows.Count==0)%>
                <div class="nodata">暂无记录...</div>
                <%/if%>
            </ul>
        </div>
        
        <!--分页页码-->
        <div class="page-list">
            {pagelist}
        </div>
        <!--/分页页码-->
        
        <input id="turl" type="hidden" value="<%linkurl("usermessage","send")%>" /><!--存在跳转的URL值-->
        <!--/发件箱-->
        <%/if%>
        
    </div>
    
    <!--版权信息-->
    <%template src="_copyright.html"%>
    <!--/版权信息-->

    <!--底部导航-->
    <div class="weui-tab foot-nav">
        <div class="weui-tab__panel">

        </div>
        <div class="weui-tabbar">
            <a href="<%linkurl("usermessage","add")%>" class="weui-tabbar__item">
                <i class="iconfont icon-edit weui-tabbar__icon"></i>
                <p class="weui-tabbar__label">发送消息</p>
            </a>
            <a href="<%linkurl("usermessage","system")%>" class="weui-tabbar__item">
                <i class="iconfont icon-notice weui-tabbar__icon"></i>
                <p class="weui-tabbar__label">系统消息</p>
            </a>
            <a href="<%linkurl("usermessage","accept")%>" class="weui-tabbar__item">
                <i class="iconfont icon-folder weui-tabbar__icon"></i>
                <p class="weui-tabbar__label">收件箱</p>
            </a>
            <a href="<%linkurl("usermessage","send")%>" class="weui-tabbar__item">
                <i class="iconfont icon-log weui-tabbar__icon"></i>
                <p class="weui-tabbar__label">发件箱</p>
            </a>
        </div>
    </div>
    <!--/底部导航-->
</div>
</body>
</html>
